{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b74050df",
   "metadata": {},
   "source": [
    "# 学习内容\n",
    "\n",
    "## 1.github education packages\n",
    "\n",
    "## 注册账号，为可以使用pycharm做准备\n",
    "\n",
    "## 2.pycharm下载官网安装和jupyter notebook的安装学习\n",
    "### 安装专业版\n",
    "\n",
    "## 3. 学习了jupyter notebook的使用\n",
    "\n",
    "### 如何在自己电脑打开jupyter notebook (cmd中直接执行jupyter notebook )\n",
    "### jupyter notebook 可以做代码的系统管理，学到了每周如何整理自己的学习内容\n",
    "## 4. 开始(python项目一,奇数中选择指定的时间minute)\n",
    "### 变量\n",
    "### if else"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cce64af7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-09-27 11:30:20.902484\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "print(datetime.today()) #打印时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "54608125",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-2-4e4a7b94241f>, line 3)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-2-4e4a7b94241f>\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m    odds=\u001b[0m\n\u001b[1;37m         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# 从奇数中选择对应的时间节点\n",
    "from datetime import datetime\n",
    "odds=\n",
    "[1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute=datetime().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"时间是奇数，时间在odds的数据中\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bf5fc2c5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "# 课本代码(项目一，从奇数中选择对应的时间节点)\n",
    "from datetime import datetime\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "# datetime.today (). minute 当前的时间的分钟\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds: \n",
    "    print (\"时间是奇数,时间在odds的数据中\")\n",
    "else: \n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3377b25f",
   "metadata": {},
   "source": [
    "## 关于datetime和time(时间模块）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "724ad6d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 10, 10, 2, 5, 34, 95640)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.today()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d4770589",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6fb85a04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2021"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# time 模块中的sleep函数可以让代码的执行暂停指定的秒数\n",
    "import time\n",
    "time.sleep(5)\n",
    "datetime.today().year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4ea6a16e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=10, tm_mday=10, tm_hour=2, tm_min=9, tm_sec=29, tm_wday=6, tm_yday=283, tm_isdst=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "101622d4",
   "metadata": {},
   "source": [
    "## 5.变量、数值、数据\n",
    "### 1.关于变量的解释https://www.cnblogs.com/xuzhichao/p/11407192.html\n",
    "### 2.变量定义的规则\n",
    "\n",
    "####  * 变量名只能是 字母、数字或下划线的任意组合\n",
    "####  * 变量名的第一个字符不能是数字\n",
    "####  * 以下关键字不能声明为变量名 ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "2e267b17",
   "metadata": {},
   "outputs": [],
   "source": [
    "name=\"xiao\"  # name是一个变量名  “=”相当于赋值  xiao是一个值（数据）；理解为将右边的值赋给左边的变量（从右往左读）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "6809caef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "wang wang\n",
      "xiao wang\n"
     ]
    }
   ],
   "source": [
    "# 案例   变量的拓展\n",
    "name1 = \"wang\"\n",
    "name2 = name1\n",
    "print(name1,name2)  # 现在执行一次代码  # 现在在这个基础上继续给变量赋值看结果\n",
    "\n",
    "name1 = \"xiao\"\n",
    "print(name1,name2)  # 同个代码（再赋予新值的情况下）又运行过的不会再运行第二次"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64a0abff",
   "metadata": {},
   "source": [
    "## 6.数值(int , float) & 字符串(str)\n",
    "\n",
    "#### *  int:整型或整数，是正或负整数，不带小数点。\n",
    "#### * float:浮点型由整数部分与小数部分组成。\n",
    "### 数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "d4b4529b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2+2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0ea190ad",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "68"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "100-4*8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "97899553",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "34.0"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(100-4*8)/2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b467bc3a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.3333333333333333"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 一些特殊案例算法  只针对除法运算  特殊运算符为 //  ，%  \n",
    "1/3   # 最后会得出一个值为无限循环小数即为浮点（不是整数）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "478308de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1//3  # 在运行除法时 要想获得一个整数则使用 //  最终值会舍去小数部分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "65ca77b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1%3  # 在除法公式运算中 如果想知道该式子的余数部分则可以使用 %  ，最后就会得出余数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "42ab1810",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对于幂次方的运算公式 需要用到的运算符号为 **  \n",
    "3**2  #5的2次方"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "b257d007",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "80"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# “=”为变量赋值\n",
    "width = 2\n",
    "height = 5 * 9-5\n",
    "width * height"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "408b068d",
   "metadata": {},
   "source": [
    "### 字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "708c7cb1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "单引号表示可以使用\"双引号\"作为字符串的一部分\n",
      "双引号表示可以使用'单引号'作为字符串的一部分\n",
      "三引号中可以使用\"双引号\" '单引号'\n",
      "也可以使用换行\n"
     ]
    }
   ],
   "source": [
    "print('单引号表示可以使用\"双引号\"作为字符串的一部分')\n",
    "print(\"双引号表示可以使用'单引号'作为字符串的一部分\")\n",
    "print('''三引号中可以使用\"双引号\" '单引号'\n",
    "也可以使用换行''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f932a46a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
